import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-05-30
 * Time: 12:18
 */
class Data{
    public int year;
    public int month;
    public int day;
//不带参数的构造方法
    public Data() {
    }
//带一个参数的构造方法
    public Data(int year) {
        this();
    }

    //代参数的构造方法
    public Data(int year, int month, int day) {
        year = year;
        month = month;
        day = day;
    }

    @Override
    public String toString() {
        return "Data{" +
                "year=" + year +
                ", month=" + month +
                ", day=" + day +
                '}';
    }
    public void fun(){
        System.out.println("调用了");
    }

    public static void main(String[] args) {
        Data data1 = new Data(2022,6,1);
        Data data2 = new Data(2022,7,1);
        Data data3 = new Data(2022,8,1);
        System.out.println(data1);
        System.out.println(data2);
        System.out.println(data3);
    }
}
 public class TheRefrigerator{
     //成员变量
     public float weight;
     public float size;
     public String name;
     public boolean normal;
     public char time;
//不带带参数的构造方法
    public TheRefrigerator() {

    }

    public TheRefrigerator(float weight, float size, String name, boolean normal, char time) {
        this.weight = weight;
        this.size = size;
        this.name = name;
        this.normal = normal;
        this.time = time;
    }
    //成员方法
    public void fresh(){
        System.out.println("低温保鲜");
    }
    public void frozen(){
        System.out.println("冷冻");
    }

    public static void main1(String[] args) {
        TheRefrigerator theRefrigerator = new TheRefrigerator();//通过new来实例化对象
        //通过theRefrigerator引用来访问成员变量 引用.成员
        System.out.println(theRefrigerator.size);
        System.out.println(theRefrigerator.weight);
        System.out.println(theRefrigerator.name);
        System.out.println(theRefrigerator.time);
        //通过theRefrigerator引用来访问成员方法  引用.方法名
        theRefrigerator.fresh();
        theRefrigerator.frozen();
    }
}
 class TEST {
    public static void main2(String[] args) {

    }
    public static void swap(int[] arr){
        int tmp = arr[0];
        arr[0] = arr[1];
        arr[1]=tmp;
    }
    //java里实现swap----通过引用来实现
    public static void main1(String[] args) {
        int[] arr = {10,20};
        System.out.println(Arrays.toString(arr));
        System.out.println("交换后");
        swap(arr);
        System.out.println(Arrays.toString(arr));
    }
}
